home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
d.t.p
/
utils
/
others
/
pcal
/
pcaldefs.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-21
|
18KB
|
598 lines
/*
* pcaldefs.h - definitions for Pcal program
*
* Revision history:
*
* 4.3 AWR 12/05/91 Revise moonfile name templates for
* consistency with current standards
* for substituting year in strings
*
* 12/03/91 Add support for -s flag
*
* 10/17/91 Add support for -Z flag and subflags;
* removed obsolete PUTSTR macro
*
* 4.2 AWR 10/08/91 Add support for -[kK] flags; renamed
* START_DAY as START_BOX for clarity
*
* 10/03/91 Add various definitions relating to
* "note/<n>"
*
* 09/30/91 Add MAX_IF_NESTING (related to "elif";
* cf. read_datefile() in readfile.c)
*
* 4.11 AWR 08/20/91 Add "nearest" keyword (as per Andy
* Fyfe)
*
* 4.1 AWR 08/16/91 Add support for -G flag
*
* 4.0 AWR 03/01/91 Add STDLIB macro for systems which
* support <stdlib.h>
*
* AWR 02/22/91 add definitions for MS-DOS support (as
* per Floyd Miller)
*
* AWR 02/19/91 revise ORD_XXX to support negative
* ordinals
*
* add definitions for Amiga support (as
* per Bill Hogsett)
*
* AWR 02/06/91 additional defs for expression
* processing
*
* AWR 02/04/91 support "year" as additional month
* name; use negative numbers for
* special ordinal codes (reserve
* positive numbers for ordinals)
*
* 01/28/91 miscellaneous new constants/macros
*
* 01/07/91 add FEB_29_OK (cf. enter_day_info())
*
* 3.0 AWR 12/10/90 support "weekday", "workday",
* "holiday", et. al.
*
* AWR 11/13/90 extracted from pcal.c; added scale and
* translation support (-x, -y, -X, -Y);
* added -j, -J flags
*
*/
/*
* System dependencies:
*/
#ifdef VMS /* VMS oddities isolated here */
#include <ssdef.h> /* required for trnlog() */
#include <descrip.h>
#define HOME_DIR "SYS$LOGIN"
#define DATEFILE "calendar.dat"
#define MOONFILE "moon%y.dat" /* '%y' replaced with year */
#define DEFAULT_OUTFILE "calendar.ps"
#define START_PATH '['
#define END_PATH ']'
#define EXIT_SUCCESS 1 /* VMS exit() parameters */
#define EXIT_FAILURE 3
#else
#ifdef AMIGA /* more oddities for Amiga */
#include <string.h>
#define PROTOS /* compiler accepts prototypes */
#define STDLIB /* system has <stdlib.h> */
#define HOME_DIR "RAM:"
#define DATEFILE "s:calendar.dat"
#define MOONFILE "s:.moon%y" /* '%y' replaced with year */
#define DEFAULT_OUTFILE "RAM:calendar.ps"
#define START_PATH '/'
#define END_PATH '/'
#else
#ifdef DOS /* even more oddities for MS-DOS */
#define DATEFILE "pcal.dat"
#define MOONFILE "moon%y.dat" /* '%y' replaced with year */
#define START_PATH '\\'
#define END_PATH '\\'
#define HOME_DIR "HOME"
#define ALT_DATEFILE "calendar" /* for backward compatibility */
#else /* neither VMS, Amiga, nor MS-DOS - assume Un*x */
#define UNIXX /* to distinguish Un*x from others */
#define HOME_DIR "HOME"
#define DATEFILE ".calendar"
#define ALT_DATEFILE "calendar" /* for backward compatibility */
#define MOONFILE ".moon%y" /* '%y' replaced with year */
#define ALT_MOONFILE "moon%y" /* analogous to ALT_DATEFILE */
#define START_PATH '/'
#define END_PATH '/'
#endif
#endif
#endif
/* define OUTFILE to DEFAULT_OUTFILE if defined, otherwise to "" (stdout) */
#ifdef DEFAULT_OUTFILE
#define OUTFILE DEFAULT_OUTFILE
#else
#define OUTFILE ""
#endif
/* PROTOS may be defined independently of __STDC__ for compilers which
* support function prototypes but are not fully ANSI-compliant
*/
#if defined(__STDC__) && ! defined(PROTOS)
#define PROTOS
#endif
/* STDLIB may be defined independently of __STDC__ for systems which
* support <stdlib.h> but are not fully ANSI-compliant
*/
#if defined(__STDC__) && ! defined(STDLIB)
#define STDLIB /* cf. {no}protos.h */
#endif
#ifdef STDLIB /* include <stdlib.h> if known to exist */
#include <stdlib.h>
#endif
/* EXIT_SUCCESS and EXIT_FAILURE should be defined in <stdlib.h>
* (or above if non-standard); define here if necessary
*/
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
/* definition of NULL (if needed) */
#ifndef NULL
#define NULL 0
#endif
/*
* Environment variables (global symbol, logical name on VMS):
*/
#define PCAL_OPTS "PCAL_OPTS" /* command-line flags */
#define PCAL_DIR "PCAL_DIR" /* calendar file directory */
#define PATH_ENV_VAR "PATH" /* cf. find_executable() (pcalutil.c) */
/*
* Function-like macros:
*/
#define FPR (void)fprintf
#define PRT (void)printf
#define PUTCHAR(_c) \
PRT((_c) == ' ' || isalnum(_c) ? "%c" : "\\%03o" , (_c) & 0377)
#define IS_LEAP(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
#define LENGTH_OF(m, y) (month_len[(m)-1] + ((m) == FEB && IS_LEAP(y)))
#define YEAR_LEN(y) (IS_LEAP(y) ? 366 : 365)
#define DAY_OF_YEAR(m, d, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) + d)
#define OFFSET_OF(m, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) % 7)
#define FIRST_OF(m, y) calc_weekday(m, 1, y)
#define START_BOX(m, y) ((FIRST_OF(m, y) - first_day_of_week + 7) % 7)
#define PREV_MONTH(m, y) ((m) == JAN ? DEC : (m) - 1)
#define PREV_YEAR(m, y) ((m) == JAN ? (y) - 1 : (y))
#define NEXT_MONTH(m, y) ((m) == DEC ? JAN : (m) + 1)
#define NEXT_YEAR(m, y) ((m) == DEC ? (y) + 1 : (y))
#define INIT_COLORS memcpy(day_color, default_color, sizeof(day_color))
#define P_LASTCHAR(p) ((p) && *(p) ? (p) + strlen(p) - 1 : NULL)
#define LASTCHAR(p) (p)[strlen(p) - 1]
#define IS_NUMERIC(p) ((p)[strspn((p), DIGITS)] == '\0')
#define IS_WILD(w) ((w) >= WILD_FIRST && (w) <= WILD_LAST)
#define MAKE_DATE(dt, m, d, y) \
if (1) { (dt).mm = m; (dt).dd = d; (dt).yy = y; } else
#define ERR(errmsg) \
FPR(stderr, E_ILL_LINE, progname, errmsg, filename, line);
#define DEBUG(f) ((debug_flags & f) != 0)
#ifdef __STDC__
#define TOLOWER(c) tolower(c)
#else
#define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
#endif
#ifndef isodigit /* rare */
#define isodigit(c) ((c) >= '0' && (c) <= '7')
#endif
#ifndef isxdigit /* ANSI standard */
#define isxdigit(c) \
(isdigit(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
/* debug subflag codes (must be distinct) - cf. pcallang.h */
#define DEBUG_DATES (1 << 1)
#define DEBUG_MOON (1 << 2)
#define DEBUG_PATHS (1 << 3)
#define DEBUG_OPTS (1 << 4)
#define DEBUG_PP (1 << 5)
#define DEBUG_TEXT (1 << 6)
/* preprocessor token codes - cf. get_token(), pcallang.h */
#define PP_DEFINE 0
#define PP_ELIF 1
#define PP_ELSE 2
#define PP_ENDIF 3
#define PP_IFDEF 4
#define PP_IFNDEF 5
#define PP_INCLUDE 6
#define PP_UNDEF 7
#define PP_OTHER -1 /* not pp token */
/* ordinal number codes - cf. get_ordinal(), pcallang.h */
#define ORD_NEGNUM -1 /* negative ordinal (-2nd == next to last) */
#define ORD_POSNUM 1 /* positive ordinal */
#define ORD_ODD 2 /* special codes for "odd" and "even" */
#define ORD_EVEN 3
#define ORD_ALL 4 /* special code for "all" used as ordinal */
#define ORD_OTHER 0 /* not ordinal token */
/* moon phase codes - cf. pcallang.h and moonphas.c; these must take the
* values 0 (NM) .. 3 (3Q) since they are used in phase calculations
*/
#define MOON_NM 0 /* new moon */
#define MOON_1Q 1 /* first quarter */
#define MOON_FM 2 /* full moon */
#define MOON_3Q 3 /* last quarter */
#define MOON_OTHER -1 /* unrecognizable */
/* date type codes - cf. date_type(), get_keywd(), and pcallang.h */
#define DT_ALL 0 /* "all" keyword" */
#define DT_NOTE 1 /* "note" keyword */
#define DT_OPT 2 /* "opt" keyword */
#define DT_YEAR 3 /* "year" keyword */
#define DT_MONTH 4 /* name of month */
#define DT_DATE 5 /* date of form dd/mm{/yy} or mm/dd{/yy} */
#define DT_EURDATE 6 /* European date of form dd <month> */
#define DT_ORDINAL 7 /* ordinal (first, 1st, ... last) */
#define DT_WEEKDAY 8 /* weekday name */
#define DT_OTHER -1 /* unrecognizable first token */
/* preposition token codes - cf. get_prep(), pcallang.h */
#define PR_BEFORE 0
#define PR_ON_BEFORE 1
#define PR_AFTER 2
#define PR_ON_AFTER 3
#define PR_NEAREST 4
#define PR_OTHER -1 /* not a preposition */
/*
* Miscellaneous other constants:
*/
#define FALSE 0 /* pseudo-Booleans */
#define TRUE 1
#define MAX_FILE_NESTING 10 /* maximum nesting level for file inclusio